import React from 'react';
import ItemOrders from '../component/item-orders';
import { fromJS } from 'immutable';
import { Button } from 'antd';

export const orderColumns = [
    {
        title: '商品',
        key: 'itemList',
        dataIndex: 'itemList',
        render: (itemList, record, index) => {
            return {
                children: <ItemOrders itemOrders={fromJS(itemList)} />,
                props: {
                    colSpan: 2
                }
            }
        }
    },
    {
        title: '成交单价/退货数量',
        key:"priceNumber",
        width: 150,
        className: 'ant-table-th-right',
        dataIndex: 'price-itemNumber',
        render: (value, record, index) => {
            return {
                props: {
                    colSpan: 0
                }
            }
        }
    },
    {
        title: '退款金额',
        width: 130,
        className: "ant-table-th-center va-t",
        dataIndex: 'actualeRfund',
        key:"actuale",
        render: (actualeRfund, record, index) => {
            return (
                <div className="real-pay">
                    <p className="total-price">&yen;{(actualeRfund ? actualeRfund : record.applyRefund  || 0).toFixed(2)}</p>
                    {
                        record.orderStatus === 'WAIT_PAY'
                            ? <p><Button type="ghost mr10 mt4">修改价格</Button></p>
                            : <p className="goods-num">共{record.itemList.reduce(((sum, item) => sum + item.itemnum), 0)}件</p>
                    }
                </div>
            )
        }
    },
    // {
    //     title: "发票信息",
    //     width: 120,
    //     key:"invoice",
    //     className: "ant-table-th-center  va-t",
    //     dataIndex: "tradeOrder",
    //     render: (tradeOrder,record) => (<span>{`${0 != tradeOrder.invoiceFlag  ? 1 == tradeOrder.invoiceType ? '普通':'增值' : '不开'}发票`}</span>)
    // }
    // ,
    // {
    //     title:"售后类型",
    //     key:"afterSaleType",
    //     width:130,
    //     className:"ant-table-th-center  va-t",
    //     dataIndex:"needReturn",
    //     render:(needReturn,record,index) => {
    //         let span = '';
    //         if(needReturn){
    //             span += "退货"
    //         }
    //         if(record.needRefund){
    //             span += "退款"
    //         }
    //
    //         return <span>{span}</span>
    //     }
    // }
]
/**
 * 退货申请单过滤条件
 */
export const Order_Waite_Audit_Filter = [
    {name: '所有退货单', key: 'AUDITED_BEFORE'},
    {name: '待审核', key: 'AUDITING'},
    {name: '已拒绝', key: 'UNAUDITED'},
];
/**
 * 退货单过滤条件
 */
export const Order_Audited_Filter = [
    {name: '所有退货单', key: 'AUDITED_AFTER'},
    {name: '待收货', key: 'WAIT_RETURN'},
    {name: '待退款', key: 'WAIT_REFUND'},
    {name: '已取消', key: 'CANCEL'},
    {name: '已完成', key: 'FINISHED'},
]
//待退款
export const Order_Wait_Refund_Filter = [
    {name: '所有待退款单', key: 'WAIT_REFUND'},
]